<script setup lang="ts" name="KnowledgeBase">
import usePublic from './hooks/usePublic'
import useInit from './hooks/useInit'

// 公共属性及方法
const { initInfo } = usePublic()

const { initPage, getListData, handleSizeChange, handleCurrentChange, resetSearch, getSummaries, spanCell, operateData } = useInit(initInfo)

onMounted(() => {
  initPage()
})
</script>

<template>
  <page-development></page-development>
</template>
<!-- <div class="user-page">
    <el-container>
      <el-aside width="240px" class="flex">
        <el-card shadow="hover" class="flex flex-1 flex-col">
          <template #header>
            <div class="card-header">
              <el-input v-model="initInfo.search.name" placeholder="分类名称">
                <template #append>
                  <el-button icon="Search" />
                </template>
              </el-input>
            </div>
          </template>
          <el-scrollbar>
            <el-tree :data="initInfo.knowledgeTypeList" @node-click="handleNodeClick" node-key="value" auto-expand-parent :highlight-current="true" :default-expanded-keys="expandNodes" />
          </el-scrollbar>
        </el-card>
      </el-aside>
      <el-container>
        <el-card shadow="hover" class="flex flex-1">
          <el-form :inline="true" @submit.prevent>
            <el-form-item label="标题">
              <el-input v-model="initInfo.search.title" placeholder="请输入标题" @keyup.enter="getListData" />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="Search" @click="getListData">{{ $t('buttons.buttonSearch') }}</el-button>
              <el-button icon="Refresh" @click="resetSearch">{{ $t('buttons.buttonReset') }}</el-button>
            </el-form-item>
          </el-form>
          <div class="flex-1 table-layout">
            <div class="table-wrap">
              <el-table :data="initInfo.list.data" border>
                <el-table-column type="index" :label="$t('page.序号')" width="60" />
                <el-table-column prop="account" label="标题" min-width="120" />
                <el-table-column prop="userName" label="标签" min-width="120" />
                <el-table-column prop="department" label="更新时间" min-width="120" />
                <el-table-column prop="operate" :label="$t('page.操作')" width="240" align="center" fixed="right">
                  <template #default="scope">
                    <el-button type="primary" icon="Eye" @click="edit(scope.row)"></el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <el-pagination
            v-if="initInfo.list.total > 0"
            v-model:currentPage="initInfo.search.page"
            v-model:page-size="initInfo.search.limit"
            :page-sizes="[20, 40, 80, 120]"
            :background="true"
            layout="total, sizes, prev, pager, next, jumper"
            :total="initInfo.list.total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange" />
        </el-card>
      </el-container>
    </el-container>
  </div> -->
<style scoped lang="scss">
.user-page {

  >.el-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: var(--el-space);

    >.el-aside {
      margin-right: var(--el-space);
      overflow: inherit;

      .el-card {
        :deep(.el-card__header) {
          padding: calc(var(--el-space) - 5px);
        }

        :deep(.el-card__body) {
          position: relative;
          display: flex;
          flex: 1;
          padding: 0;

          .el-scrollbar {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;

            .el-scrollbar__wrap {
              padding: calc(var(--el-space) / 2);
            }
          }
        }
      }
    }

    .el-container {
      .el-card {
        :deep(.el-card__body) {
          display: flex;
          flex: 1;
          flex-direction: column;
        }
      }
    }
  }
}

.table-layout {
  position: relative;
  margin: var(--el-space) 0 0;

  .table-wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    .el-table {
      width: 100%;
      height: 100%;

      .el-tag {
        margin: 2px;
      }
    }
  }
}

.el-pagination {
  align-items: center;
  justify-content: flex-end;
  margin: var(--el-space) 0 0;
}
</style>
